package com.java2_15;

import java.util.ArrayList;

public class Animal1 {
    private int age;
    protected String color;

    //静态方法只能使用静态变量和静态方法
    static ArrayList<String> list = new ArrayList<>();

    //静态代码块
    static {
        list.add("zhangsan");
    }

    //构造代码块  --  可以进行私有化的成员变量初始化
    {
        System.out.println("这是构造代码块");
    }

    public Animal1() {
        System.out.println("无参");
    }

    public Animal1(int age, String color) {
        System.out.println("有参");
        this.age = age;
        this.color = color;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public void eat(String something){
        System.out.println("动物正在吃东西");
    }

}
